package com.longteng.lesson2.controller;

import com.longteng.lesson2.task.Task2;
import com.longteng.lesson2.util.TaskUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/task")
public class TaskController {
    @Autowired
    TaskUtil taskUtil;
    @RequestMapping("/add")
    public void addTask(String id,String cron){
        String s ="0/"+cron+" * * * * ?";
        Task2 task2=new Task2();
        task2.setId(id);
        taskUtil.addTask(s,task2);
    }
    @RequestMapping("/cancel")
    public void cancelTask(String id){
        taskUtil.cancel(id);
    }

}
